package lc.q101_150;

import java.util.Deque;
import java.util.LinkedList;

public class Q155 {

    class MinStack {
        private Deque<Integer> stack = new LinkedList<>();
        private Deque<Integer> minStack = new LinkedList<>();

        public MinStack() {

        }

        public void push(int val) {
            stack.push(val);
            if (minStack.isEmpty()) {
                minStack.push(val);
            } else {
                minStack.push(Integer.min(val, minStack.peek()));
            }
        }

        public void pop() {
            stack.pop();
            minStack.pop();
        }

        public int top() {
            return stack.peek();
        }

        public int getMin() {
            return minStack.peek();
        }
    }

}
